
package com.theme.passport.controller.sys;

import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.view.R;
import com.theme.passport.entity.SysFeedbackEntity;
import com.theme.passport.service.SysFeedbackService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;



/**
 * 反馈意见
 *
 * @author live
 * @email 870459550@qq.com
 * @date 2020-12-08 15:14:01
 */
@RestController
@RequestMapping("sys/feedback")
public class SysFeedbackController {
    @Autowired
    private SysFeedbackService sysFeedbackService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:feedback:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysFeedbackService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:feedback:info")
    public R info(@PathVariable("id") Long id){
		SysFeedbackEntity sysFeedback = sysFeedbackService.getById(id);

        return R.ok().put("feedback", sysFeedback);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:feedback:save")
    public R save(@RequestBody SysFeedbackEntity sysFeedback){
        sysFeedback.setCreateTime(new Date());
        sysFeedback.setUpdateTime(new Date());
		sysFeedbackService.save(sysFeedback);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:feedback:update")
    public R update(@RequestBody SysFeedbackEntity sysFeedback){
        sysFeedback.setUpdateTime(new Date());
		sysFeedbackService.updateById(sysFeedback);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:feedback:delete")
    public R delete(@RequestBody Long[] ids){
		sysFeedbackService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
